﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MVC_Filter.Infrastructure
{
    public class CustomAuthAttribute : AuthorizeAttribute
    {
        private bool localAllowed;

        public CustomAuthAttribute(bool allowedParam)//Authorization  Filter
        {
            localAllowed = allowedParam;
        }

        protected override bool AuthorizeCore(HttpContextBase httpContext)//通过该方法来确定是否有访问该action的权限
        {
            if (httpContext.Request.IsLocal)
            {
                return localAllowed;
            }
            return true;
        }
        
    }
}